package org.zfes.snowier.zbss.xzy.router.alert;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.alert.AlertMessageDto;
import org.zfes.snowier.zbss.xzy.biz.alert.model.AlertMessage;
import org.zfes.snowier.zbss.xzy.biz.alert.service.IAlertMessageService;
import org.zfes.snowier.core.data.SelectVo;
@Controller("org.zfes.snowier.zbss.xzy.router.alert.AlertMessageController")
@RequestMapping("/xzy")
public class AlertMessageController implements BaseController {

	
	@Autowired
	private IAlertMessageService alertMessageService;
	
	
	@RequestMapping(value="/pushAlertMessage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object pushAlertMessage( AlertMessageDto alertMessage){
		alertMessageService.saveAlertMessage(alertMessage);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	
	//@RequiresPermissions(value="alertMessage:loadAlertMessageDataSet",desc="预警信息列表")
    @RequestMapping(value="/loadAlertMessageDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAlertMessageDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  alertMessageService.loadAlertMessageDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="alertMessage:createAlertMessage",desc="预警信息添加")
    @RequestMapping(value="/createAlertMessage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createAlertMessage(@RequestBody AlertMessage alertMessage){
		alertMessageService.createAlertMessage(alertMessage);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="alertMessage:loadAlertMessage",desc="预警信息加载")
    @RequestMapping(value="/loadAlertMessage/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAlertMessage(@PathVariable("id")Long id){
		Optional<AlertMessage> ops = alertMessageService.loadAlertMessageById(id);
		return ajaxQuery("alertMessage",ops);
    }
	
	//@RequiresPermissions(value="alertMessage:updateAlertMessage",desc="预警信息更新")
    @RequestMapping(value="/updateAlertMessage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateAlertMessage(@RequestBody  AlertMessage alertMessage){
		alertMessageService.updateAlertMessage(alertMessage);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="alertMessage:deletAlertMessage",desc="预警信息删除")
    @RequestMapping(value="/deleteAlertMessage/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteAlertMessage(@PathVariable("id")Long id){
		alertMessageService.deleteAlertMessage(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadAlertMessageSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAlertMessageSelectVo(){
		 List<SelectVo>  ops = alertMessageService.loadAlertMessageSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
}